草庐IT

PHPUnit 和 CodeIgniter

全部标签

phpunit:为什么这个 assertContains 通过了?

我的测试应该失败,但它通过了:publicfunctiontest_getValidProviderCodes(){$aTest=PRIDE\Reflection::executeStaticMethodForClassName(Apps_DoctorsReports::class,"getValidProviderCodes");print_r($aTest);$this->assertContains("xxxxxxxxxxxxxx",$aTest);}输出:Testingstartedat8:53AM...PHPUnit4.6.6bySebastianBergmannandcon

php - Blade 模板引擎可以与codeigniter一起使用吗?

名为blade的模板引擎可以用codeigniter还是纯php?我知道它可以与laravel一起使用,我想知道是否也可以与任何其他php框架或纯php一起使用 最佳答案 Blade可以在PHP中独立使用。这意味着您可以在CodeIgniter中轻松地使用它。https://github.com/PhiloNL/Laravel-Blade然后,您将需要composer。 关于php-Blade模板引擎可以与codeigniter一起使用吗?,我们在StackOverflow上找到一个类似

php - Codeigniter:将整个 POST 请求发送到另一个 Controller 的方法

我有一个通用Controller,它将获取POST请求并决定调用任何Controller的已知方法。将根据要求选择Controller。我还需要将整个POST请求发送到选定的方法而不进行篡改。更多说明在controller1中获取post请求,处理请求并决定调用controllerX|的known_method()|X!=1。还向该方法发送主要请求。例如。publicfunctionindex(){$post=$this->input->post();//handlingtherequestanddecidetocallthefollowingmethodofanothercontro

php - 使用 SMTP codeigniter 发送电子邮件

我正在尝试使用smtpcodeigniter发送电子邮件。我使用的代码如下:publicfunctionnotify_marketing(){$config=Array('protocol'=>'smtp','smtp_host'=>'ssl://smtp.googlemail.com','smtp_port'=>465,'smtp_user'=>'myvalidemail@gmail.com','smtp_pass'=>'*******',//myvalidemailpassword'mailtype'=>'html','charset'=>'iso-8859-1','wordwra

Travis CI 上的 PHPUnit "Could not read phpunit.xml"

尝试在TravisCI上运行PHP单元测试时,我遇到了一个奇怪的问题。.travis.ymlsudo:falselanguage:phpphp:-5.4env:-VUFIND_HOME=$PWDVUFIND_LOCAL_DIR=$PWD/localbefore_script:-pearinstallpear/PHP_CodeSniffer-pearchannel-discoverpear.phing.info-pearinstallphing/phing-composerglobalrequirefabpot/php-cs-fixer-exportPATH="$HOME/.compos

php - 是否可以使用 PHPUnit 对类文件以外的 php 文件进行单元测试?

我是PHPUnit的新手。我有一些没有任何类的php文件。我从阅读文档中了解到,PHPUnit将类视为一个单元。那么PHPUnit是否将类视为一个单元?是否可以测试其中没有任何类的php文件? 最佳答案 当然,您完全可以测试其他PHP脚本。classMyScriptTestextendsPHPUnit_Framework_TestCase{publicfunctiontestMyFunction(){include_once'path/to/script.php';$result=someFunction();$this->asse

php - 拉拉维尔 : phpunit cannot open file ExampleTest. PHP

您好,我在LaravelPHPUnit中退出了新版本,出现以下错误:Laravel:phpunitcannotopenfileExampleTest.php我不知道为什么会收到此错误。我在全局范围内安装了PHPUnit,当我在终端中运行“phpunit”时,它运行良好。但我想在特定文件上运行它,例如:phpunitExampleTest提前致谢。 最佳答案 确保您位于项目根目录并引用测试文件夹中的文件。例子:phpunittests/ExampleTest.php 关于php-拉拉维尔:

php - 在 Laravel 中使用 Mockery/phpUnit 时出错

我是一名新手开发人员,试图为现有的Laravel应用程序启动测试套件,但我没有测试经验。现在我只是想建立一些测试以获得一些信心和经验来编写更实质性的测试。我正在尝试测试模型上的关系(我意识到这不是一个非常明智的测试)并尝试创建一个模拟模型对象来这样做(我也明白最好在sqlite数据库的内存中执行此操作但主要这里的目标是测试Controller,但我不知道如何处理那里的身份验证问题)。我有以下简单、愚蠢的测试:publicfunctiontestFoo(){$lead=m::mock('Lead');$this->mock->shouldReceive('program')->once(

php - 自定义配置文件 URL Codeigniter

我正在尝试创建自定义配置文件url,如site/u/username我找到了这个Howtomakeurl/usernameincodeigniter?但直到现在它仍然显示404。当我尝试访问site/u/username我的routes.php$route['default_controller']="guest";$route['404_override']='u';我的模型functioncekuser($username){$query=$this->db->query("SELECT*FROMusertableWHEREusername='$username'");$query

javascript - 如何在 Codeigniter 中使用 Ajax 将变量从 Controller 传递到 View ?

我在将数据从Controller传递到View时遇到问题。我正在使用Ajax来执行此操作,您可以在此处查看我的Ajax代码:$(document).ready(function(){$('li.thang').click(function(){varid_thang=$(this).attr('value');$.ajax({url:baseUrl+'/Home/getImage',dataType:'json',type:'POST',data:{id_thang:id_thang},}).done(function(result){console.log(result.get_li